package com.tpay.client.event;

import com.google.gwt.event.shared.GwtEvent;
import com.google.web.bindery.event.shared.EventBus;
import com.tpay.client.CurrentUser;

public class LoginAuthenticatedEvent extends GwtEvent<LoginAuthenticatedEventHandler> {
	private static final Type<LoginAuthenticatedEventHandler> TYPE = new Type<LoginAuthenticatedEventHandler>(); 
	private final CurrentUser currentUser;
	
	public LoginAuthenticatedEvent(CurrentUser currentUser) {
		this.currentUser = currentUser;
	}
	
	public CurrentUser getCurrentUser() {
		return currentUser;
	}
	
	public static Type<LoginAuthenticatedEventHandler> getType() {
		return TYPE;
	}
	
	public static void fire(EventBus eventBus, CurrentUser currentUser) {
		eventBus.fireEvent(new LoginAuthenticatedEvent(currentUser));
	}
	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<LoginAuthenticatedEventHandler> getAssociatedType() {
		return getType();
	}

	@Override
	protected void dispatch(LoginAuthenticatedEventHandler handler) {
		handler.onLoginAuthenticated(this);
	}
}
